package com.bite.demo.controller;

import com.bite.demo.model.UserInfo;
import com.bite.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
//@ResponseBody
//@RequestMapping("/user")
public class UserController {

//    @RequestMapping("/hi")

    //属性注入
    @Autowired
    private UserService userService;

    @Qualifier("u2")
    @Autowired
    private UserInfo userInfo;

    //Setter注⼊
//    private UserService userService;
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

    //构造⽅法注⼊
//    private UserService userService;

    public UserController() {
    }
    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    public void sayHi() {
        System.out.println("Hi userController...");
        userService.sayHi();
        System.out.println(userInfo);
    }
}
